﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class communication : MonoBehaviour
{

    public GameObject dialogBox1;
    public GameObject dialogBox2;
    public Text dialogBoxText1;
    public Text dialogBoxText2;
    public GameObject guideArrow;
    public string[] signText=new string[] { "欢迎来到这个充满着美食与幸福的世界，现在老夫正式宣布你已经成为了我们的一位见习小食神。", "是吗？那太好了，我该做些什么呢？", "我们食神的职责就是用美食传递幸福，用菜肴来保留记忆。因此你要做的就是寻找人间烟火里的一道道佳肴，将它们奉献给人们，搜集美食背后的故事和人们品尝美食时所产生的食神能量。", "哦~~我明白了，我就是要去找到现在的人们都喜欢吃些什么，哪些菜比较火就行了。" 
        ,"不是的，我们的职责不仅仅是取悦人们，最重要的是寻找那些快被人遗忘，不为人所知的人间风味。让这些美味佳肴长远的流传下去，让美食的花园百花齐放才是我们的根本目标。","啊，我明白了。下面就让我来大展身手吧。"};
    private bool toNextText;
    private string currentText;
    private int currentNum=0;
    private int length;
    public  bool isfirst = true;


    private void Awake()
    {
        length = signText.Length;
        currentText = signText[currentNum];
    }


    // Start is called before the first frame update
    void Start()
    {


        if (isfirst)
        {
            dialogBoxText1.text = currentText;
        }
        isfirst = false; 
        
    }

    // Update is called once per frame
    void Update()
    {
       
      
       // dialogBoxText.text = currentText;

        if(Input.GetMouseButtonDown(0))   //0代表鼠标左键 1是右键
        {
            currentNum=currentNum+1;
            if (currentNum<length)
            {
                
                if (currentNum%2==0)
                {
                    dialogBox1.SetActive(true);
                    dialogBox2.SetActive(false);
                   
                    Debug.Log(currentNum+"情况1");
                    currentText = signText[currentNum];
                    dialogBoxText1.text = currentText;
                }
                if (currentNum % 2 == 1)
                {
                    dialogBox1.SetActive(false);
                    dialogBox2.SetActive(true);
                  
                    Debug.Log(currentNum + "情况2");
                    currentText = signText[currentNum];
                    dialogBoxText2.text = currentText;
                }

              

            }
           else
            {
                
                
                    dialogBox1.SetActive(false);
                
               
                    dialogBox2.SetActive(false);
                guideArrow.SetActive(true);
                
                
                Debug.Log("对话内容完");
            }
           
        }
    }



  

}
